<template>
	<view class="p-3">
		<view class="mb-2 flex align-center color666">
			*关闭后老师无法看到定位信息
		</view>
		<view class="item flex align-center justify-between border-bottom" v-for="(item,index) in list" :key="index">
			<view class="">{{item.vcName}}</view>
			<view class="">
				<u-switch v-model="item.intState" :activeValue="1" :inactiveValue="0" @change="change(item)" size="22">
				</u-switch>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: []
			}
		},
		onLoad() {
			this.getData()
		},
		methods: {
			getData() {
				let _this = this;
				let opts = {
					url: 'Jz/findXsYesNoDw.shtml',
				};
				let param = {
					jz_id: uni.getStorageSync('userInfo').user_id
				};
				_this.$http.httpRequest(opts, param).then(
					res => {
						console.log(res.data);
						if (res.data.code == "200") {
							let arr = res.data.data;
							_this.list = arr
						}
					},
					error => {
						console.log(error);
					}
				);
			},
			change(item) {
				let _this = this;
				let opts = {
					url: 'Jz/updJzQx.shtml',
				};
				let param = {
					xs_id: item.longId,
					type: item.intState
				};
				_this.$http.httpRequest(opts, param).then(
					res => {
						console.log(res.data);
						if (res.data.code == "200") {
							uni.showToast({
								title: "修改成功",
								icon: "none"
							})
							_this.getData()
						}
					},
					error => {
						console.log(error);
					}
				);
			}
		}
	}
</script>

<style>
	.item {
		height: 100rpx;
	}
</style>
